package edu.java.lectures.lec11.threads.basics.creation;

public class MyRunnable implements Runnable {

    private String myRunnableName;

    public MyRunnable(String myRunnableName) {
	this.myRunnableName = myRunnableName;
    }

    @Override
    public void run() {
	int counter = 0;
	while (counter < 10) {
	    System.out.println("[" + getMyRunnableName() + "]: " + counter++);
	    Thread.yield();
	    try {
		Thread.sleep(100);
	    } catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	    }
	}
	System.out.println("[" + getMyRunnableName()
		+ "] has finished its work and go to shot itself.");
    }

    public String getMyRunnableName() {
	return myRunnableName;
    }

}
